import {
  PrepaidCardParam,
  PrepaidCardResponse,
  SelectCardUpdatePriceParam,
  SelectCardUpdatePriceResponse,
} from '@/types/prepaidCard'
import fetch, { BaseResponse, loginUrl, RequestContentType } from './index'

/**
 * 获取用户选择优惠券列表
 * @param param PrepaidCardParam
 * @returns PrepaidCardResponse
 */
export async function getUserSelectList(param: PrepaidCardParam): Promise<PrepaidCardResponse> {
  const { data } = await fetch.get<PrepaidCardResponse>(
    '/api/cardcoupon/Touch/prepaid/card/user_select_list',
    {
      ...param,
    },
    { contentType: RequestContentType.FORM_URLENCODED },
  )
  return data
}
/**
 * 获取并更新价格
 * @param param SelectCardUpdatePriceParam
 * @returns SelectCardUpdatePriceResponse = {
    result: {
        data: CardUpdatePriceInfo;
        status: number;
    };
 */
export async function getConfirmUpdatePrice(
  param: SelectCardUpdatePriceParam,
): Promise<SelectCardUpdatePriceResponse> {
  const { data } = await fetch.post<SelectCardUpdatePriceResponse>(
    '/api/trade/PC/Order/ConfirmUpdatePrice/index',
    {
      ...param,
    },
    { contentType: RequestContentType.FORM_URLENCODED },
  )
  return data
}
